﻿using UnityEngine;

namespace UnityView
{
    public class LinearLayout : UILayout
    {
        public Orientation Orientation;

        protected float ContentCacheSize = 0;

        public LinearLayout(UILayout parent) : base(parent)
        {

        }

        public override void AddSubview(IViewLayout view)
        {
            base.AddSubview(view);
            // AddSubview(view, -1);
        }

        public void AddSubview(IViewLayout view, int weight)
        {
            // // Subviews.Add(new LinearLayoutInfo(view, weight));
            //
            // var rt = view.RectTransform;
            // Rect rect = GetRect(rt);
            // rt.SetParent(RectTransform);
            // // rt.anchorMin = rt.anchorMax = UIConstant.TopLeftVector2;
            // rt.sizeDelta = rect.size;
            //
            // switch (Orientation)
            // {
            //     case Orientation.Vertical:
            //         rt.anchoredPosition = new Vector2(view.Width * 0.5f, -view.Height * 0.5f - ContentCacheSize);
            //         ContentCacheSize += rect.height;
            //         RectTransform.sizeDelta = new Vector2(Width, ContentCacheSize);
            //
            //         break;
            //     case Orientation.Horizontal:
            //         break;
            // }
        }
    }
}
